FROM java:8
MAINTAINER mr
# 定义参数
ENV JAR_NAME="mr-generator"
ENV VERSION="1.0.0"
#ENV JAR_FILE="whuanet-generator-service/target/${JAR_NAME}-${VERSION}.jar"
ENV JAR_FILE="target/${JAR_NAME}.jar"
ENV JAR_EXPOSE="8880"
ENV WORK_DIR="/export/"
# 创建容器运行的工作目录
RUN mkdir ${WORK_DIR}
WORKDIR ${WORK_DIR}
# DEPLOY JARs
#ADD ${JAR_FILE} ${WORK_DIR}/${JAR_NAME}-${VERSION}.jar
ADD ${JAR_FILE} ${WORK_DIR}/${JAR_NAME}.jar
ARG JAVA_OPTS="-Xmx512m -Xms512m -Xmn256m -XX:MetaspaceSize=256M -XX:MaxMetaspaceSize=256M"
ARG JVM_SERVER_FIXED_ARGS="-server -XX:+DisableExplicitGC -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+UseCMSInitiatingOccupancyOnly \
-XX:CMSInitiatingOccupancyFraction=70 -XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses -XX:+CMSClassUnloadingEnabled -XX:+ParallelRefProcEnabled \
-XX:+CMSScavengeBeforeRemark -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC \
-XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps"
ARG JVM_GC_LOG_PATH="-XX:ErrorFile=${WORK_DIR}/logs/gc/hs_err_pid%p.log -XX:HeapDumpPath=${WORK_DIR}/logs/gc -Xloggc:${WORK_DIR}/logs/gc/gc%t.log"
# 设置容器的时间
ENV TZ="Asia/Shanghai"
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# 定义参数
ENV JAVA_OPTS=${JAVA_OPTS}
ENV JVM_SERVER_FIXED_ARGS=${JVM_SERVER_FIXED_ARGS}
ENV JVM_GC_LOG_PATH=${JVM_GC_LOG_PATH}
#对外暴漏的端口号
EXPOSE ${JAR_EXPOSE}
#指定容器启动时需要执行的命令
ENTRYPOINT java ${JAVA_OPTS} ${JVM_SERVER_FIXED_ARGS} ${JVM_GC_LOG_PATH} -Djava.security.egd=file:/dev/./urandom -Dfile.encoding=UTF-8 -jar ${WORK_DIR}/${JAR_NAME}.jar
#ENTRYPOINT java ${JAVA_OPTS} ${JVM_SERVER_FIXED_ARGS} ${JVM_GC_LOG_PATH} -Djava.security.egd=file:/dev/./urandom -Dfile.encoding=UTF-8 -jar ${WORK_DIR}/${JAR_NAME}-${VERSION}.jar